var accountBalance = context .AccountBalanceByDate .Where(a => a.Date == context.AccountBalanceByDate .Where(b => b.AccountId == a.AccountId && b.Date < date).Max(b => b.Date));